package com.example.myworkers.controller;/*
 *编写者：段光映
 */
import com.example.myworkers.model.Money;
import com.example.myworkers.service.MoneyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "Money")
@RestController
@RequestMapping("/money")
public class MoneyController {
    @Autowired
    private MoneyService moneyService;
    @ApiOperation(value = "添加方法")
    @PostMapping("/addParty")
    @CrossOrigin
    public int addMoney(@RequestBody Money money){
        System.out.println("进入添加方法");
        return moneyService.insertMoney(money);
    }
    @ApiOperation(value = "删除方法")
    @GetMapping("/deleteMoney")
    public int deleteMoney(int payid) {
        System.out.println("进入删除方法");
        int monvalue = 0;
        if (payid != 0) {
            Money money=new Money();
            money.setPayid(payid);
            monvalue=moneyService.deleteMoney(money);
        }
        return monvalue;
    }
    @ApiOperation(value = "查找党员缴费情况所有信息")
    @GetMapping("/getAll")
    public List<Money> selectAllMoney(Money money){
        System.out.println("进入查询所有党员缴费情况信息方法");
        List<Money> listmoney=moneyService.selectAllMoney(money);
        return listmoney;
    }
    @ApiOperation(value = "更新党员缴费情况信息方法")
    @PutMapping("/UpdateMoney")
    public int updateMoney(Money money){
        System.out.println("进入更新党员缴费情况信息方法");
        return moneyService.updateMoney(money);
    }
    @ApiOperation(value = "对党员缴费情况信息的单条查询方法")
    @GetMapping()
    public Money selectMoney(int payid){
        Money money=new Money();
        System.out.println("进入党员缴费情况信息单条查询法");
        if (payid!=0){
            Money money1=new Money();
            money1.setPayid(payid);
            money=moneyService.selectMoney(money1);
        }
        return money;
    }
}


